package com.ruoyi.tester.executor.expression;

import com.ruoyi.tester.executor.ExpressionContext;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @author SongJun
 * @description 解析数字大于函数gt(x)
 * @date 2022/4/21 15:13
 */
@Component
public class ExpGt implements ExpressionAnalysis {
    @Override
    public String getExpressionName() {
        return "gt";
    }

    @Override
    public String getDescription() {
        return "gt(x) 返回当前数字类型的上下文是否大于数字类型x的值;";
    }

    @Override
    public Object analysis(ExpressionContext context, String... param) {
        BigDecimal bodyDecimal = new BigDecimal(context.getContext().toString());
        BigDecimal paramDecimal = new BigDecimal(param[0]);
        return bodyDecimal.compareTo(paramDecimal) > 0;
    }
}
